/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battleroom;

import com.jme3.app.state.AbstractAppState;

/**
 *
 * @author Adam
 */
public class GameState extends AbstractAppState{
    private static GameState inst = new GameState();
    
    public static GameState get()
    { return inst; }
    
    private int targetCount = 0;
    private int targetsHit = 0;
    private float timeElapsed = 0;
    private float timeAllowed = 0;    
    
    public GameState()
    {
        
    }
    
    public void setTargetCount(int count){ targetCount = count; }
    public int getTargetCount(){ return targetCount; }
    public float getElapsedTime(){ return timeElapsed; }
    public float getAllowedTime(){ return timeAllowed; }
    public void setAllowedTime(float time){ timeAllowed = time; }
    public int getTargetsHit(){ return targetsHit; }
    public void setTargetsHit(int hit){ targetsHit = hit; }
    
    @Override
    public void update(float tpf)
    {
        super.update(tpf);
        
        timeElapsed += tpf;
        
        if(getTargetsHit() >= getTargetCount() && getElapsedTime() < getAllowedTime())
        {
            System.out.println("YOU WIN THE GAME YOU WINNER!");
        }else if(getElapsedTime() >= getAllowedTime())
        {
            System.out.println("YOU LOSE THE GAME YOU LOSER!");
        }
        
        if(timeElapsed%5 < .02)
        {
            System.out.println("Targets hit:\t" + getTargetsHit() + "/" + getTargetCount());
            System.out.println("Time left:\t" + (getAllowedTime() - getElapsedTime())) ;
        }
    }
}
